@echo off
rem
rem options
rem   list              -- list all sql server instances
rem   start {instance}  -- start sql server instance
rem   stop  {instance}  -- stop sql server instance


if  "%1"=="list"  goto :list_instance
if  "%1"=="start" goto :start_instance
if  "%1"=="stop"  goto :stop_instance
goto :parameters

rem --------------------------------------------------------------
rem
rem                   Parameters
rem
rem --------------------------------------------------------------

:parameters
echo Parameters for this command are
echo    list             -- list all available instances of Sql Server
echo    start {instance} -- start Instance
echo    stop {instance}  -- stop Instance
echo  aborting.
goto :eof
rem exit 1

rem --------------------------------------------------------------
rem
rem                   List Instance
rem
rem --------------------------------------------------------------

rem On my current system, this is what SC displays
rem     DISPLAY_NAME: SQL Server (FRED)
rem I suspect that this will will be diffent on every variety of machine.
rem So, this particular function will change over time.

:list_instance

echo List instances for 2008
sc query type= service state= "all" | find "SQL Server ("


goto :eof

rem --------------------------------------------------------------
rem
rem                   Start Instance
rem
rem --------------------------------------------------------------


:start_instance
echo Start Instance
rem get rid of the 'start' parameter
shift      

echo %1

goto :eof

rem --------------------------------------------------------------
rem
rem                   List Instance
rem
rem --------------------------------------------------------------

:stop_instance
echo Stop Instance
goto :eof

  set var=
:LOOP
  if "%1"=="" goto :DONE
  set var=%var% %1
  shift
  goto :L
:DONE
  echo. VAR=%var%
